﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Nirvana
{

    /// <summary>
    /// 对象池资源策略
    /// </summary>
    [AddComponentMenu("Nirvana/Pool/Pool Strategy")]
    public sealed class PoolStrategy : MonoBehaviour
    {
        [Header("限制创建对象数量，缓存池中没有空闲对象，就不创建")]
        [SerializeField]
        private bool isLimitSpwan = false;
        /// <summary>
        /// 限制创建对象数量，缓存池中没有空闲对象，就不创建
        /// </summary>
        public bool IsLimitSpwan
        {
            get { return isLimitSpwan; }
        }

        [Header("prefab空闲时释放时间")]
        [SerializeField]
        private float prefabReleaseAfterFree = 30f;
        /// <summary>
        /// prefab空闲时释放时间
        /// </summary>
        public float PrefabReleaseAfterFree
        {
            get
            {
                return this.prefabReleaseAfterFree;
            }
        }
        [Header("实例对象空闲时释放时间，-1：不释放")]
        [SerializeField]
        private float instanceReleaseAfterFree = 60f;
        /// <summary>
        /// 实例对象空闲时释放时间，-1：不释放
        /// </summary>
        public float InstanceReleaseAfterFree
        {
            get
            {
                return this.instanceReleaseAfterFree;
            }
        }
        [SerializeField]
        [Header("实例对象在池中能够创建的最大数")]
        private int instancePoolCount = 5;
        /// <summary>
        /// 实例对象在池中能够创建的最大数
        /// </summary>
        public int InstancePoolCount
        {
            get
            {
                return this.instancePoolCount;
            }
        }
    }
}

